<?php


namespace app\api\service;

use tmcore\base\BaseService;
use think\facade\Request;

class ConfigService extends BaseService
{
    /**
     * 获取配置
     * @param $params
     * @return array
     */
    public static function getConfig($params) : array
    {
        $base_config = com_get_config('base', 'sys');

        if($params['type'] == 1) {
            return [
                'loginConfig' => [
                    'config' => com_get_config('h5_channel', 'sys')
                ],
                'tabbarConfig' => DiyService::detail(['type' => 1, 'name' => 'tabbar']),
                'styleConfig' => DiyService::detail(['type' => 1, 'name' => 'style']),
                'sysConfig' => [
                    'base' => [
                        'app_name' => $base_config['app_name'],
                        'app_logo' => $base_config['app_logo'],
                    ],
                    'record' => com_get_config( 'record','sys')
                ],
            ];
        } else {
            return [
                'loginConfig' => [
                    'config' => com_get_config('pc_channel', 'sys')
                ],
                'styleConfig' => DiyService::detail(['type' => 2, 'name' => 'home_page']),
                'sysConfig' => [
                    'adminPath' => Request::domain(true) . '/admin/',
                    'appPath' => Request::domain(true) . '/app/',
                    'base' => [
                        'pc_name' => $base_config['pc_name'],
                        'pc_logo' => $base_config['pc_logo'],
                        'pc_favicon' => $base_config['pc_favicon'],
                        'seo_keyword' => $base_config['seo_keyword'],
                        'seo_desc' => $base_config['seo_desc'],
                    ],
                    'record' => com_get_config( 'record','sys')
                ],
            ];
        }
    }


}